//
// Created by Jisam on 05/10/2024 20:09.
// Solution of  b
#include <bits/stdc++.h>

#define  int long long
#define  endl "\n"
using namespace std;


signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int n = min(s.length(),t.length());
    if(s == t){
        cout << 0;
        exit(0);
    }
    for(int i = 0 ; i < n ; i ++)
    {
        if(s[i] != t[i]){
            cout << i + 1;
            exit(0);
        }
    }
    cout << n + 1;
    return 0;
}